package com.cn.auth.serviceImpl.sys;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import com.cn.auth.po.sys.AuthMenu;
import org.springframework.stereotype.Service;

import com.cn.auth.dao.sys.MenuDao;
import com.cn.auth.service.sys.MenuService;

/**
 * Service实现类
 * @author Maochao-zhu
 *
 */
@Service("MenuServiceImpl")
public class MenuServiceImpl implements MenuService {
	@Resource
	MenuDao menuDao;

	@Override
	public Integer insertMenu(AuthMenu menu) {
		// TODO Auto-generated method stub
		return menuDao.insertMenu(menu);
	}

	@Override
	public Integer deleteMenuById(String[] ids) {
		// TODO Auto-generated method stub
		return menuDao.deleteMenuById(ids);
	}

	@Override
	public Integer updateMenuById(AuthMenu menu) {
		// TODO Auto-generated method stub
		return menuDao.updateMenuById(menu);
	}

	@Override
	public AuthMenu getMenuById(Integer id) {
		// TODO Auto-generated method stub
		return menuDao.getMenuById(id);
	}

	@Override
	public List<AuthMenu> getMenuList(AuthMenu menu) {
		// TODO Auto-generated method stub
		return menuDao.getMenuList(menu);
	}
	
	@Override
	public List<AuthMenu> getMenuLeft(String cname){
		List<AuthMenu> parentList = new ArrayList<AuthMenu>();
		//一级菜单
		parentList = menuDao.getMenuListByPid(0,cname);
		for(AuthMenu m : parentList){
			//二级菜单
			List<AuthMenu> childList = menuDao.getMenuListByPid(m.getId(),cname);
			m.setChildList(childList);
		}
		return parentList;
	} 
	


	@Override
	public Integer getMenuListCount(AuthMenu menu) {
		return menuDao.getMenuListCount(menu); 
	}

}
